/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.hsos.ai.swa.simplebookstore.boundary.jsf;

import de.hsos.ai.swa.simplebookstore.control.BookRepository;
import de.hsos.ai.swa.simplebookstore.entity.Book;
import javax.enterprise.inject.Model;
import javax.inject.Inject;

/**
 *
 * @author rainer
 */
@Model
public class BookUIModel {
    @Inject
    BookRepository bookRepository;
    @Inject
    Book book;
    String isbn=null;
    boolean render=false;

    public BookUIModel() {
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public boolean isRender() {
        return render;
    }

    public void setRender(boolean render) {
        this.render = render;
    }
    
    public void addBook() {
        this.bookRepository.addBook(this.book);
    }
    
    public void findBook() {
        if(isbn!=null) {
            this.book = this.bookRepository.findBook(this.isbn);
            this.render = true;
        } else {
            this.render = false;
        } 
    }
}
